#include "QNerveTissue.h"

QNerveTissue::QNerveTissue()
{
    type = 0;
    memPot = 0;
    tempMemPot = 0;
    id = 0;
    curveVisible = false;
    switchedOn = false;
    sender = true;
}

int QNerveTissue::getType(void)
{
    return type;
}

void QNerveTissue::addTempMemPot(double _tempMemPot)
{
    tempMemPot += _tempMemPot;
}
void QNerveTissue::spreadMemPot(void)
{
    for (int i=0; i<receiver.size(); ++i)
    {
        receiver[i]->addTempMemPot(memPot);
    }
}
void QNerveTissue::rotMemPot(void)
{
    memPot = tempMemPot;
    tempMemPot = 0;
}

void QNerveTissue::setID(int _id)
{
    id = _id;
    emit idChanged(id);
}
int QNerveTissue::getID(void)
{
    return id;
}

void QNerveTissue::addReceiver(QNerveTissue* _receiver)
{
    receiver << _receiver;
}
void QNerveTissue::removeReceiverAt(int at)
{
    receiver.removeAt(at);
}
void QNerveTissue::clearReceiverList(void)
{
    receiver.clear();
}
QList<QNerveTissue*> QNerveTissue::getReceiverList(void)
{
    return receiver;
}
QList<int> QNerveTissue::getReceiverIDList(void)
{
    return receiverID;
}

void QNerveTissue::setPos(QPointF _pos)
{
    pos = _pos;
}
QPointF QNerveTissue::getPos(void)
{
    return pos;
}

void QNerveTissue::updateReceiverIDList(void)
{
    receiverID.clear();
    for (int i=0; i<receiver.size(); ++i)
    {
        receiverID << receiver[i]->getID();
    }
}
void QNerveTissue::setReceiverIDList(QList<int> _receiverID)
{
    receiverID = _receiverID;
}

bool QNerveTissue::isCurveVisible(void)
{
    return curveVisible;
}
bool QNerveTissue::isSender(void)
{
    return sender;
}

double QNerveTissue::getMemPot(void)
{
    return memPot;
}
double QNerveTissue::getMultiplier(void)
{
    return multiplier;
}
double QNerveTissue::getRelaxTime(void)
{
    return relaxTime;
}

QString QNerveTissue::getState(void)
{
    return QString("error");
}

void QNerveTissue::setMemPot(double _memPot)
{
    memPot = _memPot;
    emit memPotChanged(memPot);
}
void QNerveTissue::setMultiplier(double _multiplier)
{
    multiplier = _multiplier;
    emit multiplierChanged(multiplier);
}
void QNerveTissue::setRelaxTime(double _relaxTime)
{
    relaxTime = _relaxTime;
    emit relaxTimeChanged(relaxTime);
}

void QNerveTissue::switchMode(void)
{
    ;
}
bool QNerveTissue::isSwitchedOn(void)
{
    return switchedOn;
}

void QNerveTissue::toggleCurveVisible(bool _curveVisible)
{
    curveVisible = _curveVisible;
    emit curveVisibleToggled(curveVisible);
}
void QNerveTissue::toggleIsSender(bool _sender)
{
    sender = _sender;
    emit isSenderToggled(sender);
}
